#!/usr/bin/env python3
# -*- coding: utf-8 -*-

__author__ = 'lumeng'

'''
@filename game_stats
@@created on 2017-11-13
@poject:python-shoot-game
@auther:teffy
'''

import json,os

class GameStats():
    '''跟踪游戏的统计信息'''

    def __init__(self,settings):
        self.settings = settings
        self.game_active = False
        self.level = 1
        self.ship_left = self.settings.ship_limit
        if os.path.exists(self.settings.config_file):
            with open(self.settings.config_file) as f:
                highcore = json.load(f)
                if highcore and self.settings.config_high_score_key in highcore:
                    self.high_score = int(highcore[self.settings.config_high_score_key])
                else:
                    self.high_score = 0
        else:
            self.high_score = 0
        self.reset_stats()


    def reset_stats(self):
        self.shp_left = self.settings.ship_limit
        self.score = 0
        self.level = 1
        self.ship_left = self.settings.ship_limit

